package com.fyzk.betzhushu.ssq;

import com.fyzk.activity.lottery.shuzicai.BallInfo;
import com.fyzk.betzhushu.ZhuShuBase;

import java.math.BigInteger;
import java.util.List;

public class SSQ_ZhuShu extends ZhuShuBase{

	@Override
	public long betZhuShu(List<List<BallInfo>> balls) {
		int dan = 0;
		int hong = 0;
		int lan = 0;
		
		for (int i = 0; i < balls.size(); i++) {
			List<BallInfo> infos = balls.get(i);
			int selectedNum = 0;
			for (int j = 0; j < infos.size(); j++) {
				BallInfo info = infos.get(j);
				if (info.isSelected()) {
					selectedNum++;
				}
			}
			switch (i) {
			case 0:
				dan = selectedNum;
				break;
			case 1:
				hong = selectedNum;
				break;
			case 2:
				lan = selectedNum;
				break;
			default:
				break;
			}
		}
		return getZhuShu_common(hong, lan);
	}
	
	/**
	 * 计算普通注数
	 */
	public long getZhuShu_common(int hong, int lan){
		if (hong < 6) {
			return 0;
		}else if (hong == 6) {
			return lan;
		}else{
			BigInteger big = c_x_y(hong).divide(c_x_y(6)).divide(c_x_y(hong - 6));
			return  big.longValue()* lan;
		}
	}
	
	private BigInteger c_x_y(int n){
		BigInteger big = new BigInteger(""+n);
		
		return (n == 0) ? new BigInteger("1") : big.multiply(c_x_y(n - 1)) ;
	}

}
